function dt=var_select_neighbor_val_surv(dt,t)

%VAR_SELECT_NEIGHBOR_VAL_SURV runs VAR_SELECT_NEIGHBOR_VAL for time series
%Syntax dt=var_select_neighbor_val_surv(dt,t)
%   dt is a variable of the type created by read_data_microvigene_surv
%   t is the vector with times where to build a predictor

%sum(dt.y>T)/(length(dt.y)-sum((~dt.dead)&(dt.y<T)))
if nargout <2
    t=sort(unique(dt.y));
    t(1)=[];
end
if ~isfield(dt,'dead')
    dt.dead=ones(length(dt.y),1);
end

for i=1:length(t);
    %disp('----------------------')
    %disp(['For T=',num2str(t(i))])
    %disp('----------------------')
    di=dt;
    if isfield(di,'predict')
        di=rmfield(di,'predict');
    end
    %exclude not deads for less than t
    ii=find((di.y<t(i))&(~di.dead)); %indexes of those to be excluded
    di.x(ii,:)=[];
    di.nx(ii,:)=[];
    di.y(ii,:)=[];
    di.y=di.y>=t(i);
    n=length(di.x(:,1));
    di=var_select_neighbor_val(di,[],['(',num2str(i),'/',num2str(length(t)),')   ','t=',num2str(t(i))]);
    di.predict.T=t(i);
    di.predict.exclude=ii;
    dt.predict(i)=di.predict;
end